package com.kedi.journalismcenter.write.dao.mapper;

import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 
 *
 * @author: 	陈辽逊
 * @date: 		2019/7/23  17:00
 */
@Mapper
public interface PcGoldenRadioMapper {
	
	/**
	 * 				 创建评书所有数据信息
	 * @param		 map
	 * @return		 返回一个封装数据对象istorytelling
	 */
	@Insert("INSERT storytelling " 
			+"(title,url,playtimes) "
			+"VALUE " 
			+"((#{map.title}),(#{map.url}),(#{map.playtimes}))")
	int istorytelling(@Param("map")Map map);
	
	/**
	 * 				  根据id修改评书所有数据信息
	 * @param		 map
	 * @return		 返回一个封装数据对象storytelling
	 */
	@Update("UPDATE storytelling  " 
			+"SET "  
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), " 
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), " 
			+"playtimes = (CASE WHEN (#{map.playtimes}) IS NULL THEN playtimes ELSE (#{map.playtimes}) END) " 
			+"WHERE storytel_id = (#{map.storytelid})")
	int storytelling(@Param("map")Map map);
	
	/**
	 * 				  创建戏曲所有信息
	 * @param		 map
	 * @return		 返回一个数据对象iopera
	 */
	@Insert("INSERT opera " 
			+"(title,url,playtimes) " 
			+"VALUE " 
			+"((#{map.title}),(#{map.url}),(#{map.playtimes}))")	
	int iopera(@Param("map")Map map);
	
	/**
	 * 				  根据id修改戏曲所有信息
	 * @param		 map
	 * @return		 返回一个数据对象opera
	 */
	@Update("UPDATE opera  " 
			+"SET "  
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), " 
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), " 
			+"playtimes = (CASE WHEN (#{map.playtimes}) IS NULL THEN playtimes ELSE (#{map.playtimes}) END) " 
			+"WHERE opera_id = (#{map.operaid})")
	int opera(@Param("map")Map map);
	
	/**
	 * 				  创建音乐所有信息
	 * @param		 map
	 * @return       返回一个封装数据对象imusic
	 */
	@Insert("INSERT music " 
			+"(title,url,playtimes) " 
			+"VALUE " 
			+"((#{map.title}),(#{map.url}),(#{map.playtimes}))")
	int imusic(@Param("map")Map map);
	
	/**
	 * 				  根据id修改音乐所有信息
	 * @param		 map
	 * @return       返回一个封装数据对象music
	 */
	@Update("UPDATE music  " 
			+"SET "  
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), " 
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), " 
			+"playtimes = (CASE WHEN (#{map.playtimes}) IS NULL THEN playtimes ELSE (#{map.playtimes}) END) " 
			+"WHERE music_id = (#{map.musicid})")
	int music(@Param("map")Map map);
	
	/**
	 * 				  创建实评所有信息
	 * @param		 map
	 * @return		 返回一个封装数据对象ireview
	 */
	@Insert("INSERT review " 
			+"(title,url,playtimes) " 
			+"VALUE " 
			+"((#{map.title}),(#{map.url}),(#{map.playtimes}))")
	
	int ireview(@Param("map")Map map);
	
	/**
	 * 				  根据id修改实评所有信息
	 * @param		 map
	 * @return		 返回一个封装数据对象review
	 */
	@Update("UPDATE review  " 
			+"SET "  
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), " 
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), " 
			+"playtimes = (CASE WHEN (#{map.playtimes}) IS NULL THEN playtimes ELSE (#{map.playtimes}) END) " 
			+"WHERE review_id = (#{map.reviewid})")
	int review(@Param("map")Map map);
}
